<template>
	<view class="main">
		<zmm-watermark :watermark="watermark"></zmm-watermark>
		<ul class="list">
			<li v-for="(item,index) in list" :key="index" @tap="routerBack(item.id)">
				<view class="info">
					<image :src="item.avatar" mode=""></image>
					<view class="name">
						{{item.username}}
					</view>
				</view>
			</li>
		</ul>
	</view>
</template>

<script>
	import {
		innerinfo,
		myTeam
	} from '@/api/inner.js'
	export default{
		data(){
			return{
				userInfo:{},
				list:[],
				prevPageRoute:'',
				type:'',
				watermark:'',
				status:'',
				page:1,
				last_page:''
			}
		},
		onLoad(e) {
			this.watermark = uni.getStorageSync('watermark')
			if(e.type){
				this.type = e.type
			}
			this.status = e.status
			this.getInfo()
		},
		onReachBottom() {
			if(this.page == this.last_page){
				uni.showToast({
					title:'没有更多了',
					icon:'none'
				})
				return
			}else{
				this.page++
				this.getList()
			}
		},
		methods:{
			routerBack(id){
				if(this.type){
					uni.redirectTo({
						url:`/pages/pageB/data/profitLoss?id=${id}&type=${this.type}`
					})
				}else{
					if(this.status == 1){
						uni.redirectTo({
							url:`/pages/innerOrder/innerOrder?id=${id}`
						})
					}
					if(this.status == 2){
						uni.redirectTo({
							url:`/pages/index/dbOrder?id=${id}&type=1`
						})
					}
				}
			},
			async getInfo(){
				let res = await innerinfo()
				this.userInfo = res.data
				console.log(res)
				this.getList()
			},
			async getList(){
				if(this.page == 1){
					this.list = []
				}
				let res = await myTeam({
					page_size:15,
					username:this.userInfo.username,
					page:this.page
				})
				console.log(res)
				res.data.data.forEach(item => {
					this.list.push(item)
				})
				this.last_page = res.data.last_page
			}
		}
	}
</script>

<style lang="scss" scoped>
	.main{
		min-height: calc(100vh - 44px);
		background-color: #F6F7F9;
		.header{
			padding: 30px 15px 15px;
			background-color: #fff;
			margin-bottom: 7px;
			.search{
				width: 100%;
				border-radius: 10px;
				background-color: #F2F3F7;
				display: flex;
				align-items: center;
				padding: 10px 12px;
				image{
					width: 12px;
					height: 12px;
					margin-right: 7px;
				}
				input{
					flex: 1;
				}
				
			}
		}
		.list{
			padding-top: 20px;
			li{
				display: flex;
				justify-content: space-between;
				align-items: center;
				padding: 12px 15px;
				background-color: #fff;
				margin-bottom: 10px;
				.info{
					display: flex;
					align-items: center;
					color: #3D3D3D;
					image{
						width: 42px;
						height: 42px;
						border-radius: 5px;
						margin-right: 15px;
					}
				}
				.post{
					font-size: 12px;
					color: #999999;
				}
			}
		}
	}
</style>